﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenLab.DAL.ViewModel
{
    public class ListAdmissions : IListAdmissions
    {
        public int id { get; set; }
        public string nom { get; set; }
        public string sexe { get; set; }
        public string list { get; set; }
        public string valid { get; set; }
        public int resultatvalide { get; set; }

        public ListAdmissions()
        {
        }

        public DataTable GetAll(DateTime sDate, DateTime eDate)
        {
            string rqt = "select * from [dbo].[ListDemandeByDate](@sDate,@eDate)";
            SqlParameter[] parameters = new SqlParameter[2]
            {
                new SqlParameter("@sDate", ToDBValue(sDate)),
                new SqlParameter("@eDate", ToDBValue(eDate)),
            };
            try
            {
                return SqlHelper.ExecuteDataTable(rqt, parameters);
            }
            catch (Exception)
            {
                throw new Exception("Cannot Load Data!");
            }
            
        }
        protected object ToDBValue(object value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }
		
    }
}
